Skip to content

Conversation

@rachelmcr
Copy link
Contributor

@rachelmcr rachelmcr commented May 31, 2023

Closes: #9840

Description

This PR increases the app's resilience when the app receives a String instead of an expected value type for the stockQuantity on Product or ProductVariation. (This is a known decoding error that users have experienced.)

Core sends the stock quantity as an Int or null, and we already convert that to an optional Decimal to handle plugins that allow decimal quantities. This PR adds failsafe decoding from String to Decimal, too.

Testing instructions

We don't know the exact plugins that can cause this behavior, but you can test using a tool like Charles Proxy or Proxyman to intercept and modify the response:

  1. Set a breakpoint in your tool of choice for requests to the /wc/v3/products endpoint.
  2. Build and run the app.
  3. Open the Products tab.
  4. Modify the response so a product's stock_quantity field returns a string representing a number or null value (e.g. "stock_quantity": "1" or "stock_quantity": "").
  5. Execute the response and confirm the app loads the product list.

You can repeat the same steps with the variations list for a variable product, modifying the same fields in the response for a variation.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@rachelmcr rachelmcr added feature: product list Related to the product list. feature: variation list Related to the variations list for variable products. category: reliability Related to app’s reliability, accuracy, and perceived waiting time labels May 31, 2023
@rachelmcr rachelmcr added this to the 13.9 milestone May 31, 2023
@rachelmcr rachelmcr changed the title [Reliability] Add failsafe decoding when string/data is received for stock_quantity [Reliability] Add failsafe decoding when String is received for stock_quantity May 31, 2023
@rachelmcr rachelmcr marked this pull request as ready for review May 31, 2023 12:01
@rachelmcr rachelmcr requested review from Ecarrion and ThomazFB May 31, 2023 12:01
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 31, 2023

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr9850-efd5803 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@Ecarrion Ecarrion self-assigned this May 31, 2023
@peril-woocommerce
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 2 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@rachelmcr rachelmcr enabled auto-merge May 31, 2023 17:06
@rachelmcr rachelmcr merged commit c968da6 into trunk May 31, 2023
@rachelmcr rachelmcr deleted the issue/9840-nsdecimal-decoding-fallbacks branch May 31, 2023 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: reliability Related to app’s reliability, accuracy, and perceived waiting time feature: product list Related to the product list. feature: variation list Related to the variations list for variable products.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Reliability] Add failsafe decoding for NSDecimal when string/data is received

4 participants